package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.vo.CheckGroupVO;
import com.itheima.health.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

public interface SetmealMapper extends BaseMapper<Setmeal> {

    @Insert("insert into t_setmeal_checkgroup values(#{id},#{checkgroupId})")
    void addSetmealAndGroupInfo(@Param("id") Integer id, @Param("checkgroupId") Integer checkgroupId);

    @Select("select name,age,remark,img,sex from t_setmeal where id = #{id}")
    SetmealVO findSetmealById(@Param("id") int id);

     @Select("SELECT tc.id, tc.name ,tc.remark " +
             "FROM  t_setmeal_checkgroup  tsc , t_checkgroup tc " +
             "WHERE  tc.id = tsc.CHECKGROUP_ID " +
             "and tsc.SETMEAL_ID = #{id}")
    List<CheckGroupVO> findCheckGroupInfosBySetmealId(@Param("id") int id);
  @Select("SELECT tc.name " +
          "FROM  t_checkgroup_checkitem tcc , t_checkitem tc " +
          "WHERE tcc.CHECKITEM_ID = tc.ID " +
          "and tcc.CHECKGROUP_ID = #{id}")
    List<CheckItem> findCheckItemsByCheckGroupId(@Param("id") Integer id);

    @Select("select * from t_setmeal")
    List<Setmeal> findAllSetmeal();

}
